using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Apache.Cassandra;


namespace Cassandraemon
{


	public static class SuperColumnExtensions
	{
		public static SuperColumn SetName(this SuperColumn source, object name)
		{
			source.Name = name.ToCassandraByte();
			return source;
		}
		
		public static SuperColumn SetColumn(this SuperColumn source, Column column)
		{
			source.Columns = new List<Column>();
			source.Columns.Add(column);
			return source;
		}
		
		public static SuperColumn SetColumn(this SuperColumn source, object name, object value)
		{
			return source.SetColumn(new Column().SetNameValue(name, value));
		}
		
		public static SuperColumn SetColumn(this SuperColumn source, object name, object value, long unixTime)
		{
			return source.SetColumn(new Column().SetNameValueTimestamp(name, value, unixTime));
		}
		
		public static SuperColumn SetColumn(this SuperColumn source, object name, object value, int ttl)
		{
			return source.SetColumn(new Column().SetNameValueTtl(name, value, ttl));
		}
		
		public static SuperColumn SetColumn(this SuperColumn source, object name, object value, long unixTime, int ttl)
		{
			return source.SetColumn(new Column().SetNameValueTimestampTtl(name, value, unixTime, ttl));
		}
		
		
		public static SuperColumn SetColumnList(this SuperColumn source, IEnumerable<Column> columnList)
		{
			source.Columns = new List<Column>();
			source.Columns.AddRange(columnList);
			return source;
		}
		
		public static SuperColumn SetColumnList(this SuperColumn source, object obj)
		{
			return SetColumnList(source, MappingUtil.MappingColumn(obj));
		}
		
		
		public static SuperColumn AddColumn(this SuperColumn source, Column column)
		{
			if(source.Columns == null) source.Columns = new List<Column>();
			source.Columns.Add(column);
			return source;
		}
		
		public static SuperColumn AddColumn(this SuperColumn source, object name, object value)
		{
			return source.AddColumn(new Column().SetNameValue(name, value));
		}
		
		public static SuperColumn AddColumn(this SuperColumn source, object name, object value, long unixTime)
		{
			return source.AddColumn(new Column().SetNameValueTimestamp(name, value, unixTime));
		}
		
		public static SuperColumn AddColumn(this SuperColumn source, object name, object value, int ttl)
		{
			return source.AddColumn(new Column().SetNameValueTtl(name, value, ttl));
		}
		
		public static SuperColumn AddColumn(this SuperColumn source, object name, object value, long unixTime, int ttl)
		{
			return source.AddColumn(new Column().SetNameValueTimestampTtl(name, value, unixTime, ttl));
		}
		
		public static SuperColumn AddColumnList(this SuperColumn source, IEnumerable<Column> columnList)
		{
			if(source.Columns == null) source.Columns = new List<Column>();
			source.Columns.AddRange(columnList);
			return source;
		}
		
		public static SuperColumn AddColumnList(this SuperColumn source, object obj)
		{
			return AddColumnList(source, MappingUtil.MappingColumn(obj));
		}
		
		public static SuperColumn SetTtl(this SuperColumn source, int ttl)
		{
			source.Columns.SetTtl(ttl);
			return source;
		}
		
		
		public static List<SuperColumn> Add(this ICollection<SuperColumn> source, object name, Column column)
		{
			source.Add(new SuperColumn().SetName(name).SetColumn(column));
			return source.ToList();
		}
		
		public static List<SuperColumn> Add(this ICollection<SuperColumn> source, object name, object columnName, object columnValue)
		{
			return source.Add(name, new Column().SetNameValue(columnName, columnValue));;
		}
		
		public static List<SuperColumn> Add(this ICollection<SuperColumn> source, object name, IEnumerable<Column> columnList)
		{
			source.Add(new SuperColumn().SetName(name).SetColumnList(columnList));
			return source.ToList();
		}
		
		public static List<SuperColumn> Add(this ICollection<SuperColumn> source, object name, object obj)
		{
			return Add(source, name, MappingUtil.MappingColumn(obj));
		}
		
		public static List<SuperColumn> SetTtl(this List<SuperColumn> source, int ttl)
		{
			foreach(var superColumn in source)
			{
				superColumn.SetTtl(ttl);
			}
			return source;
		}
	}
}
